package main;

import java.sql.SQLException;
import java.util.List;

import repository.TermRepository;

import model.TermModel;

import util.QueryConverter;
import entity.Term;

public class Main {

	public static void main(String[] args) {

		String selectQueryString = "PREFIX id:      <http://dblp.rkbexplorer.com/sparql/>"
				+ "PREFIX akt: <http://www.aktors.org/ontology/portal#>"
				+ "PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>"
				+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
				+ "PREFIX foaf:    <http://xmlns.com/foaf/0.1/>"
				+ "select ?nomeInstituicao ?telefone"
				+ " where"
				+ "{"
				+ "?article akt:has-author ?halevy. "
				+ "?article rdf:type akt:Article-Reference . "
				+ "?article2 akt:has-date ?date . "
				+ "?anotherAuthor akt:full-name ?anotherAuthorName . " + "}";

		QueryConverter queryConverter = new QueryConverter();

		// Transform Select Queries to Ask Queries.
		String askQueryString = queryConverter
				.convertSelectToAsk(selectQueryString);

		TermModel graphModel = new TermModel();

		List<Term> term = graphModel.extractTermWithQuery(selectQueryString);

		try {

			new TermRepository().saveTerm(term, selectQueryString,
					askQueryString);

		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
